
package tests.laurens.gui_ti07;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;

import javax.swing.JFrame;


public class Painter extends JFrame {

	private static final long serialVersionUID = 1L;

	// set up GUI and register mouse event handler
	public Painter() {
		repaint();
	} // end Painter constructor

	public static String sep = (System.getProperty("file.separator") == "/") ? "/" : "\\";

	public static Image getDudesImage(String file) {
		Image image = null;

		String pathToImages = "images" + sep;

		try {
			image = Toolkit.getDefaultToolkit().getImage(
					Painter.class.getResource(pathToImages + file));
		} catch(Exception e) {}
		return image;
	}

	// Path to GUI icons (used for application- and frame icons)
	public void paint(Graphics g) {
		// super.paint( g ); // clears drawing area

		Image background = getDudesImage("dat_cat.gif");

		// Manual
		// int W = 100, H = 100;

		// Dynamic
		// int W = this.getWidth(), H = this.getHeight();

		// Fill entire desktop
		// int W = Toolkit.getDefaultToolkit().getScreenSize().width;
		// int H = Toolkit.getDefaultToolkit().getScreenSize().height;

		// 1:1
		int W = background.getWidth(this);
		int H = background.getHeight(this);

		g.drawImage(background, 0, 0, W, H, this);
		g.fillOval(10, 10, 10, 10);

		repaint();
	}

}
